home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / Libraries / Evaluate / TestEval.c < prev    next >
C/C++ Source or Header  |  1994-05-28  |  523b  |  41 lines

  1. /*
  2.  
  3.  
  4. TestEval- a very simple shell to see if the evaluate library works
  5.  
  6.  
  7. */
  8.  
  9.  
  10. #include    "Evaluate.h"
  11. #include    "Sane.h"
  12. #include    "stdio.h"
  13.  
  14. main()
  15. {
  16.     extended    x;
  17.     Str255        expr = "\psin(2*x)/x";
  18.     OSErr        theErr;
  19.     decform        format;
  20.     
  21.     printf("Expression: %#s\n",expr);
  22.     
  23.     x = 2.0;
  24.     
  25.     theErr = Evaluate(&expr,&x);
  26.     
  27.     if (theErr)
  28.     {
  29.         SysBeep(1);
  30.         NumToString(theErr,&expr);
  31.         printf("Error %#s\n",expr);
  32.     }
  33.     else
  34.     {
  35.         format.style = FIXEDDECIMAL;
  36.         format.digits = 8;
  37.         
  38.         num2str(&format,x,&expr);
  39.         printf("%#s\n",expr);
  40.     }
  41. }